<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>键盘事件类型</title>
</head>
<body>
    <input type="text" id="username">
    <script>
        //一般加在windos,document,input
        username.onkeydown = function(){
            console.log('键盘按下')
        }
        username.onkeyup = function(){
            console.log('键盘弹上')
        }
    </script>
</body>
</html>